<?php

namespace App\Http\Controllers\Agency;

use App\Services\FollowService;
use App\Services\LogService;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use hg\apidoc\annotation as Apidoc;

/**
 * 记录管理
 * @Apidoc\Group("crm")
 */

class LogController extends Controller
{
    /**
     * @Apidoc\Title ("记录管理-跟进记录")
     * @Apidoc\Url("/agency/followsLog")
     * @Apidoc\Method("POST")
     * @Apidoc\Header("Authorization", type="string",require=true, desc="Bearer + accessToken")
     * @Apidoc\Param("page",type="int",require=false,desc="页数")
     * @Apidoc\Param("pageSize",type="int",require=false,desc="每页条数")
     * @Apidoc\Param("mid",type="int",require=false,desc="客户id")
     * @Apidoc\Param("username",type="string",require=false,desc="客户昵称")
     * @Apidoc\Param("mode",type="string",require=false,desc="跟进方式")
     * @Apidoc\Param("content",type="string",require=false,desc="小记内容")
     * @Apidoc\Param("startTime",type="string",require=false,desc="开始时间")
     * @Apidoc\Param("endTime",type="string",require=false,desc="筛选结束时间")
     * @Apidoc\Param("content",type="string",require=false,desc="筛选跟进内容")
     * @Apidoc\Param("userid",type="int",require=false,desc="跟进人")
     * @Apidoc\Returned("id",type="int",desc="id")
     * @Apidoc\Returned("mid",type="int",desc="客户id")
     * @Apidoc\Returned("mode",type="int",desc="跟进方式")
     * @Apidoc\Returned("intention",type="int",desc="客户意向")
     * @Apidoc\Returned("content",type="string",desc="跟进内容")
     * @Apidoc\Returned("nexttime",type="string",desc="下次跟进时间")
     * @Apidoc\Returned("imgs",type="array",desc="图片数组")
     * @Apidoc\Returned("optionid",type="int",desc="跟进人id")
     * @Apidoc\Returned("optionname",type="string",desc="跟进人名称")
     * @Apidoc\Returned("created_at",type="string",desc="跟进时间")
     * @Apidoc\Returned("modeText",type="int",desc="字段注释")
     * @Apidoc\Returned("typeText",type="string",desc="字段注释")
     * @Apidoc\Returned("annex",type="array",desc="批注",children={
     *     @Apidoc\Returned("id",type="int",desc="id"),
     *     @Apidoc\Returned("content",type="string",desc="跟进内容"),
     *     @Apidoc\Returned("optionid",type="int",desc="跟进人id"),
     *     @Apidoc\Returned("optionname",type="string",desc="跟进人名称"),
     *     @Apidoc\Returned("created_at",type="string",desc="跟进时间"),
     *     @Apidoc\Returned("created_at",type="string",desc="跟进时间"),
     *
     *})
     */
    public function followsLog(Request $request ,LogService $logService)
    {
        $params = $request->input();
        $params['uid'] = $this->getUid();
        $params['aid'] = $this->getAid();
        $params['type'] = 1;  //只展示销售记录
        $result = $logService->followsLog($params);
        return $this->responseSuccess($result);
    }

    /**
     * @Apidoc\Title ("记录管理-流转记录")
     * @Apidoc\Url("/agency/rotatesLog")
     * @Apidoc\Method("POST")
     * @Apidoc\Header("Authorization", type="string",require=true, desc="Bearer + accessToken")
     * @Apidoc\Param("page",type="int",require=false,desc="页数")
     * @Apidoc\Param("pageSize",type="int",require=false,desc="每页条数")
     * @Apidoc\Param("mid",type="int",require=false,desc="客户id")
     * @Apidoc\Param("username",type="string",require=false,desc="客户昵称")
     * @Apidoc\Param("startTime",type="string",require=false,desc="跟进开始时间")
     * @Apidoc\Param("endTime",type="string",require=false,desc="跟进结束时间")
     * @Apidoc\Param("optionid",type="string",require=false,desc="操作人id")
     * @Apidoc\Returned("id",type="int",desc="id")
     * @Apidoc\Returned("mid",type="int",desc="客户id")
     * @Apidoc\Returned("explain",type="int",desc="流转说明")
     * @Apidoc\Returned("remark",type="int",desc="备注")
     * @Apidoc\Returned("optionid",type="int",desc="操作人id")
     * @Apidoc\Returned("optionname",type="string",desc="操作人名称")
     * @Apidoc\Returned("created_at",type="string",desc="操作时间")
     *
     *})
     */
    public function rotatesLog(Request $request ,LogService $logService)
    {
        $params = $request->input();
        $params['uid'] = $this->getUid();
        $params['aid'] = $this->getAid();
        $result = $logService->rotatesLog($params);
        return $this->responseSuccess($result);
    }

    /**
     * @Apidoc\Title ("记录管理-分配记录")
     * @Apidoc\Url("/agency/allotLog")
     * @Apidoc\Method("POST")
     * @Apidoc\Header("Authorization", type="string",require=true, desc="Bearer + accessToken")
     * @Apidoc\Param("page",type="int",require=false,desc="页数")
     * @Apidoc\Param("pageSize",type="int",require=false,desc="每页条数")
     * @Apidoc\Param("mid",type="int",require=false,desc="客户id")
     * @Apidoc\Param("username",type="string",require=false,desc="客户昵称")
     * @Apidoc\Param("startTime",type="string",require=false,desc="跟进开始时间")
     * @Apidoc\Param("endTime",type="string",require=false,desc="跟进结束时间")
     * @Apidoc\Param("optionid",type="string",require=false,desc="操作人id")
     * @Apidoc\Returned("id",type="int",desc="id")
     * @Apidoc\Returned("mid",type="int",desc="客户id")
     * @Apidoc\Returned("olduserid",type="int",desc="原归属人id")
     * @Apidoc\Returned("oldusername",type="int",desc="原归属人")
     * @Apidoc\Returned("optionid",type="int",desc="操作id")
     * @Apidoc\Returned("optionname",type="string",desc="操作名称")
     * @Apidoc\Returned("created_at",type="string",desc="操作时间")
     *})
     */
    public function allotLog(Request $request ,LogService $logService)
    {
        $params = $request->input();
        $params['uid'] = $this->getUid();
        $params['aid'] = $this->getAid();
        $result = $logService->allotLog($params);
        return $this->responseSuccess($result);
    }

    /**
     * @Apidoc\Title ("记录管理-删除记录")
     * @Apidoc\Url("/agency/deleteLog")
     * @Apidoc\Method("POST")
     * @Apidoc\Header("Authorization", type="string",require=true, desc="Bearer + accessToken")
     * @Apidoc\Param("page",type="int",require=false,desc="页数")
     * @Apidoc\Param("pageSize",type="int",require=false,desc="每页条数")
     * @Apidoc\Param("mid",type="int",require=false,desc="客户id")
     * @Apidoc\Param("username",type="string",require=false,desc="客户昵称")
     * @Apidoc\Param("startTime",type="string",require=false,desc="跟进开始时间")
     * @Apidoc\Param("endTime",type="string",require=false,desc="跟进结束时间")
     * @Apidoc\Param("userid",type="string",require=false,desc="操作人id")     * @Apidoc\Returned("id",type="int",desc="id")
     * @Apidoc\Returned("mid",type="int",desc="客户id")
     * @Apidoc\Returned("optionid",type="int",desc="操作人id")
     * @Apidoc\Returned("optionname",type="string",desc="操作人名称")
     * @Apidoc\Returned("created_at",type="string",desc="操作时间")
     *
     *})
     */
    public function deleteLog(Request $request ,LogService $logService)
    {
        $params = $request->input();
        $params['uid'] = $this->getUid();
        $params['aid'] = $this->getAid();
        $result = $logService->deleteLog($params);
        return $this->responseSuccess($result);
    }
}
